home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / dvglue10.arc / UISIGNAL.C < prev    next >
C/C++ Source or Header  |  1988-08-13  |  2KB  |  64 lines

  1. /*======================================================*/
  2. /*  UISIGNAL.C                                          */
  3. /*                                                      */
  4. /* (c) Copyright 1988 Ralf Brown.  All Rights Reserved. */
  5. /*======================================================*/
  6.  
  7. #include "tvapi.h"
  8. #include "tvstream.h"
  9. #include "tvui.h"
  10.  
  11. /*======================================================*/
  12.  
  13. static void (*signal_handlers[TV_MENU_END-TV_HMOVE+1])(NOTIFY_MSG far *) ;
  14.  
  15. /*======================================================*/
  16. /*======================================================*/
  17.  
  18. static void far UIsignal_handler(void)
  19. {
  20.    NOTIFY_MSG msg ;
  21.    PARMLIST2 p ;
  22.    register int count ;
  23.  
  24.    while (TVmbx_size(NIL) > 0)
  25.       {
  26. /* do what TVreadmail() does, but such that DS doesn't have to equal SS */
  27.       p.num_args = 0 ;
  28.       TVsendmsg(READ_MSG, MAILME, NIL, (PARMLIST *)&p) ;
  29.       count = (int) p.arg[1] ;
  30.       if (count > sizeof(msg))
  31.          count = sizeof(msg) ;
  32.       while (count-- > 0)
  33.          ((char *)&msg)[count] = ((char far *)p.arg[0])[count] ;
  34.       msg.event -= MS_NOTIFY ;
  35.       if (msg.event >= TV_HMOVE && msg.event <= TV_MENU_END && signal_handlers[msg.event] != NULL)
  36.          (*signal_handlers[msg.event])((NOTIFY_MSG far *)&msg) ;
  37.       }
  38. }
  39.  
  40. /*======================================================*/
  41. /* UIsignal   set up handlers for specified notify msgs */
  42. /*   Ralf Brown 8/1/88                                  */
  43. /*======================================================*/
  44.  
  45. void (* pascal UIsignal(int signal,OBJECT window,void (*handler)(NOTIFY_MSG far *)))(NOTIFY_MSG far *)
  46. {
  47.    void (*old_handler)(NOTIFY_MSG far *) ;
  48.  
  49.    old_handler = signal_handlers[signal] ;
  50.    signal_handlers[signal] = handler ;
  51.    if (handler != NULL)
  52.       {
  53.       TVwin_async(window,UIsignal_handler) ; /* we may not have installed the */
  54.                                              /* handler on this window yet */
  55.       TVwin_notify(window,signal) ;
  56.       TVwin_allow(window,signal) ;
  57.       }
  58.    else
  59.       TVwin_cancel(window,signal) ;
  60.    return old_handler ;
  61. }
  62.  
  63. /* End of UISIGNAL.C */
  64.